{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "33e0ae41",
   "metadata": {},
   "source": [
    "### python启蒙\n",
    "\n",
    "* 下载anaconda及配置环境\n",
    "* 输入第一行代码\n",
    "* 观察标准库"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "46c3889b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello world\n"
     ]
    }
   ],
   "source": [
    "print(\"hello world\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1adc1162",
   "metadata": {},
   "source": [
    "### 标准库=函数+模块\n",
    "\n",
    "* [标准库用法查询](https://docs.python.org/3/library/index.html)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "599ffbd0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'win32'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import sys\n",
    "sys.platform"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "efe2c248",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)]\n"
     ]
    }
   ],
   "source": [
    "print(sys.version)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "9cd7cd9e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'D:\\\\python_XU'"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import os\n",
    "os.getcwd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "3d59e127",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "environ{'ALLUSERSPROFILE': 'C:\\\\ProgramData',\n",
       "        'APPDATA': 'C:\\\\Users\\\\TING\\\\AppData\\\\Roaming',\n",
       "        'COMMONPROGRAMFILES': 'C:\\\\Program Files\\\\Common Files',\n",
       "        'COMMONPROGRAMFILES(X86)': 'C:\\\\Program Files (x86)\\\\Common Files',\n",
       "        'COMMONPROGRAMW6432': 'C:\\\\Program Files\\\\Common Files',\n",
       "        'COMPUTERNAME': 'DESKTOP-NCATGH5',\n",
       "        'COMSPEC': 'C:\\\\Windows\\\\system32\\\\cmd.exe',\n",
       "        'CONDA_DEFAULT_ENV': 'base',\n",
       "        'CONDA_EXE': 'C:\\\\ProgramData\\\\Anaconda3\\\\Scripts\\\\conda.exe',\n",
       "        'CONDA_PREFIX': 'C:\\\\ProgramData\\\\Anaconda3',\n",
       "        'CONDA_PROMPT_MODIFIER': '(base) ',\n",
       "        'CONDA_PYTHON_EXE': 'C:\\\\ProgramData\\\\Anaconda3\\\\python.exe',\n",
       "        'CONDA_SHLVL': '1',\n",
       "        'DRIVERDATA': 'C:\\\\Windows\\\\System32\\\\Drivers\\\\DriverData',\n",
       "        'FPS_BROWSER_APP_PROFILE_STRING': 'Internet Explorer',\n",
       "        'FPS_BROWSER_USER_PROFILE_STRING': 'Default',\n",
       "        'HOMEDRIVE': 'C:',\n",
       "        'HOMEPATH': '\\\\Users\\\\TING',\n",
       "        'INTEL_DEV_REDIST': 'C:\\\\Program Files (x86)\\\\Common Files\\\\Intel\\\\Shared Libraries\\\\',\n",
       "        'LOCALAPPDATA': 'C:\\\\Users\\\\TING\\\\AppData\\\\Local',\n",
       "        'LOGONSERVER': '\\\\\\\\DESKTOP-NCATGH5',\n",
       "        'MIC_LD_LIBRARY_PATH': 'C:\\\\Program Files (x86)\\\\Common Files\\\\Intel\\\\Shared Libraries\\\\compiler\\\\lib\\\\mic',\n",
       "        'NUMBER_OF_PROCESSORS': '4',\n",
       "        'ONEDRIVE': 'C:\\\\Users\\\\TING\\\\OneDrive',\n",
       "        'OS': 'Windows_NT',\n",
       "        'PATH': 'C:\\\\ProgramData\\\\Anaconda3;C:\\\\ProgramData\\\\Anaconda3\\\\Library\\\\mingw-w64\\\\bin;C:\\\\ProgramData\\\\Anaconda3\\\\Library\\\\usr\\\\bin;C:\\\\ProgramData\\\\Anaconda3\\\\Library\\\\bin;C:\\\\ProgramData\\\\Anaconda3\\\\Scripts;C:\\\\ProgramData\\\\Anaconda3\\\\bin;C:\\\\ProgramData\\\\Anaconda3\\\\condabin;C:\\\\Program Files (x86)\\\\Common Files\\\\Intel\\\\Shared Libraries\\\\redist\\\\intel64\\\\compiler;C:\\\\Windows\\\\system32;C:\\\\Windows;C:\\\\Windows\\\\System32\\\\Wbem;C:\\\\Windows\\\\System32\\\\WindowsPowerShell\\\\v1.0;C:\\\\Windows\\\\System32\\\\OpenSSH;C:\\\\ProgramData\\\\Anaconda3;C:\\\\ProgramData\\\\Anaconda3\\\\Scripts;C:\\\\ProgramData\\\\Anaconda3\\\\Library\\\\bin;C:\\\\ProgramData\\\\Anaconda3\\\\Library\\\\mingw-w64\\\\bin;C:\\\\Users\\\\TING\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python39\\\\Scripts;C:\\\\Users\\\\TING\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python39;C:\\\\Users\\\\TING\\\\AppData\\\\Local\\\\Microsoft\\\\WindowsApps;C:\\\\Users\\\\TING\\\\AppData\\\\Local\\\\GitHubDesktop\\\\bin;C:\\\\ProgramData\\\\Anaconda3;C:\\\\ProgramData\\\\Anaconda3\\\\Scripts;C:\\\\ProgramData\\\\Anaconda3\\\\Library\\\\bin;C:\\\\ProgramData\\\\Anaconda3\\\\Library\\\\mingw-w64\\\\bin;.;D:\\\\Pycharm\\\\PyCharm 2021.2.1\\\\bin;.;c:\\\\program files (x86)\\\\mydrivers\\\\drivergenius;c:\\\\program files (x86)\\\\mydrivers\\\\drivergenius\\\\ksoft',\n",
       "        'PATHEXT': '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC',\n",
       "        'PROCESSOR_ARCHITECTURE': 'AMD64',\n",
       "        'PROCESSOR_IDENTIFIER': 'Intel64 Family 6 Model 158 Stepping 9, GenuineIntel',\n",
       "        'PROCESSOR_LEVEL': '6',\n",
       "        'PROCESSOR_REVISION': '9e09',\n",
       "        'PROGRAMDATA': 'C:\\\\ProgramData',\n",
       "        'PROGRAMFILES': 'C:\\\\Program Files',\n",
       "        'PROGRAMFILES(X86)': 'C:\\\\Program Files (x86)',\n",
       "        'PROGRAMW6432': 'C:\\\\Program Files',\n",
       "        'PROMPT': '(base) $P$G',\n",
       "        'PSMODULEPATH': 'C:\\\\Program Files\\\\WindowsPowerShell\\\\Modules;C:\\\\Windows\\\\system32\\\\WindowsPowerShell\\\\v1.0\\\\Modules',\n",
       "        'PUBLIC': 'C:\\\\Users\\\\Public',\n",
       "        'PYCHARM': 'D:\\\\Pycharm\\\\PyCharm 2021.2.1\\\\bin;',\n",
       "        'SESSIONNAME': 'Console',\n",
       "        'SYSTEMDRIVE': 'C:',\n",
       "        'SYSTEMROOT': 'C:\\\\Windows',\n",
       "        'TEMP': 'C:\\\\Users\\\\TING\\\\AppData\\\\Local\\\\Temp',\n",
       "        'TMP': 'C:\\\\Users\\\\TING\\\\AppData\\\\Local\\\\Temp',\n",
       "        'USERDOMAIN': 'DESKTOP-NCATGH5',\n",
       "        'USERDOMAIN_ROAMINGPROFILE': 'DESKTOP-NCATGH5',\n",
       "        'USERNAME': 'TING',\n",
       "        'USERPROFILE': 'C:\\\\Users\\\\TING',\n",
       "        'WINDIR': 'C:\\\\Windows',\n",
       "        'JPY_INTERRUPT_EVENT': '2320',\n",
       "        'IPY_INTERRUPT_EVENT': '2320',\n",
       "        'JPY_PARENT_PID': '1068',\n",
       "        'TERM': 'xterm-color',\n",
       "        'CLICOLOR': '1',\n",
       "        'PAGER': 'cat',\n",
       "        'GIT_PAGER': 'cat',\n",
       "        'MPLBACKEND': 'module://ipykernel.pylab.backend_inline'}"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "os.environ"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "794a09ea",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.date(2021, 9, 8)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import datetime\n",
    "datetime.date.today()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "2e3a66de",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "8"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import datetime\n",
    "datetime.date.today().day"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "a5f48601",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "9"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.today().month"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "c7d66987",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2021"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.today().year"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "e5a5ae7b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2021-09-08'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.isoformat(datetime.date.today())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f3c7778f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'13:37'"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import time\n",
    "time.strftime(\"%H:%M\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "61952350",
   "metadata": {},
   "outputs": [],
   "source": [
    "#%y 两位数的年份表示（00-99）\n",
    "#%Y 四位数的年份表示（000-9999）\n",
    "#%m 月份（01-12）\n",
    "#%d 月内中的一天（0-31）\n",
    "#%H 24小时制小时数（0-23）\n",
    "#%I 12小时制小时数（01-12）\n",
    "#%M 分钟数（00=59）\n",
    "#%S 秒（00-59）\n",
    "#%a 本地简化星期名称\n",
    "#%A 本地完整星期名称\n",
    "#%b 本地简化的月份名称\n",
    "#%B 本地完整的月份名称\n",
    "#%c 本地相应的日期表示和时间表示\n",
    "#%j 年内的一天（001-366）\n",
    "#%p 本地A.M.或P.M.的等价符\n",
    "#%U 一年中的星期数（00-53）星期天为星期的开始\n",
    "#%w 星期（0-6），星期天为星期的开始\n",
    "#%W 一年中的星期数（00-53）星期一为星期的开始\n",
    "#%x 本地相应的日期表示\n",
    "#%X 本地相应的时间表示\n",
    "#%Z 当前时区的名称\n",
    "#%% %号本身"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "63e40ee7",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
